
in vec2 position;
in vec2 tcoord0; 

uniform sampler2D tex0;
uniform vec2 viewport;

centroid out vec2 tc0;

void main() 
{ 
	// copy uvs

	// normalize texture coords between 0.0 -> 1.0

	ivec2 size = textureSize(tex0, 0);
	vec2 coord = vec2(tcoord0.s / size.s, tcoord0.t / size.t);

	tc0 = coord;

	// convert position from vec2 to vec4 

	vec4 pos = vec4(position, 0.0, 1.0);

	// transform from pixel to device space

	pos.x /= viewport.x;
	pos.y /= viewport.y;

	pos.xy *= 2.0;
	pos.xy -= 1.0;

	// copy the position

	gl_Position = pos;
}